<template>
	<view class="content">
		<u-swiper class="swiper" :height='300' :list="swiperList" keyName="image" :autoplay="true" circular :radius='0'>
		</u-swiper>
		<view class="attendanceUserInfo">
			<view class="guide" @click="logout()">
				退出登录
				<u-icon class='icon' name="arrow-right-double" color="#FFFFFF" size="24"></u-icon>
			</view>
			<view class="top" v-if="!showPatient">
				<view class="left">
					<view class="name" >
						<view class="label u-flex" style="display: flex;" @click="toUserCenter">
							{{user.realName}}
							<label style="color: gray;">{{'['+uName[user.type]+']'}}</label>
							<label style="padding-left: 20rpx;"><u-icon name="edit-pen-fill" color="#2979ff" size="50"></u-icon></label>
						</view>
						
					</view>
					<view class="cardNumber">{{ user.type == 2 ?('建档号:'+user.uid):('职称:'+user.jobTitle)  }}</view>
					<view class="balance">
						<view class="label"> 用户名:</view>
						<view class="money">{{user.nickName}}</view>
						<view class="label" style="padding-left: 30rpx;"> 年龄:</view>
						<view class="money">{{user.age}}</view>
						<view class="label" style="padding-left: 30rpx;"> 性别:</view>
						<view class="money">{{user.sex==1?'男':'女'}}</view>
					</view>
				</view>
<!-- 				<view class="right">
					<img class="QrCodeImg" src="../../static/QRcode.png" @click="QrCodeImg">
					<view class="label">个人信息</view>
				</view> -->
			</view>
			<view class="addVisitorsBox" v-else>
				<view class="addVisitors" @click="addVisitors">添加就诊人</view>
			</view>
			<view class="bottom" v-if="user.type > 1">
				<view class="bottomItem" @click="registrationRecord">
					<img class='image' src="../../static/registrationRecord.png">
					<view>{{ user.type==2 ?'挂号记录':'待诊病人' }}</view>
				</view>
				<view class="bottomItem" @click="myVisitors">
					<img class='image' src="../../static/addAttendanceUser.png">
					<view>{{ user.type==2 ?'我的病历':'诊疗历史' }}</view>
				</view>
			</view>
			
		</view>
		<view class="outpatientService" v-if="user.type==2">
			<view class="label">门诊服务</view>
			<view class="itemList">
				<u-grid :border="false" col="4">
					<u-grid-item v-for="(baseListItem,baseListIndex) in outpatientServiceList" :key="baseListIndex"
						@click="navigatorPages(baseListItem)">
						<img class="iconImage" :src="baseListItem.url"
							style="	width: 100rpx;height: 100rpx;display: flex;justify-content: center;align-items: center;">
						<text class="grid-text">{{baseListItem.title}}</text>
					</u-grid-item>
				</u-grid>
			</view>
		</view>
		<view class="outpatientService" v-if="user.type==3">
			<view class="label">门诊服务</view>
			<view class="itemList">
				<u-grid :border="false" col="4">
					<u-grid-item v-for="(baseListItem,baseListIndex) in outpatientServiceList2" :key="baseListIndex"
						@click="navigatorPages(baseListItem)">
						<img class="iconImage" :src="baseListItem.url"
							style="	width: 100rpx;height: 100rpx;display: flex;justify-content: center;align-items: center;">
						<text class="grid-text">{{baseListItem.title}}</text>
					</u-grid-item>
				</u-grid>
			</view>
		</view>
<!-- 		<view class="patientService">
			<view class="label">住院服务</view>
			<view class="itemList">
				<u-grid :border="false" col="4">
					<u-grid-item v-for="(baseListItem,baseListIndex) in patientServiceList"
						@click="navigatorPages(baseListItem)" :key="baseListIndex">
						<img class="iconImage" :src="baseListItem.url"
							style="	width: 100rpx;height: 100rpx;display: flex;justify-content: center;align-items: center;">
						<text class="grid-text">{{baseListItem.title}}</text>
					</u-grid-item>
				</u-grid>
			</view>
		</view> -->
		
		<view class="outpatientService" v-if="user.type==1">
			<view class="label">医院管理</view>
			<view class="itemList">
				<u-grid :border="false" col="4">
					<u-grid-item v-for="(baseListItem,baseListIndex) in reportSearchList2" :key="baseListIndex"
						@click="navigatorPages(baseListItem)">
						<img class="iconImage" :src="baseListItem.url"
							style="	width: 100rpx;height: 100rpx;display: flex;justify-content: center;align-items: center;">
						<text class="grid-text">{{baseListItem.title}}</text>
					</u-grid-item>
				</u-grid>
			</view>
		</view>
		
		<view class="reportSearch" v-if="user.type==1">
			<view class="label">用户管理</view>
			<view class="itemList">
				<u-grid :border="false" col="4">
					<u-grid-item v-for="(baseListItem,baseListIndex) in reportSearchList" :key="baseListIndex"
						@click="navigatorPages(baseListItem)">
						<img class="iconImage" :src="baseListItem.url"
							style="	width: 100rpx;height: 100rpx;display: flex;justify-content: center;align-items: center;">
						<text class="grid-text">{{baseListItem.title}}</text>
					</u-grid-item>
				</u-grid>
			</view>
		</view>
		<u-picker :show="showPatientList" :columns="patientList" keyName="name" @confirm='confirmPatient'></u-picker>
	</view>
</template>

<script>
	import appRequest from "@/common/appRequestUrl.js";
	export default {
		data() {
			return {
				uName:['/','管理员','患者','医生'],
				//当前就诊人信息
				nowPatient: {
					id: 1,
					image: 'https://s3.bmp.ovh/imgs/2022/08/22/dc720e5d0256c3dd.png',
					name: '张三',
					balance: '300',
					cardNo: '85245685296311245'
				},
				//是否展示就诊人
				showPatient: false,
				//是否展示就诊人列表
				showPatientList: false,
				//首页宣传图轮播
				swiperList: [{
					image: 'https://s3.bmp.ovh/imgs/2022/08/02/6ec2e316251a8ff9.png',
				}, {
					image: 'https://s3.bmp.ovh/imgs/2022/08/02/6ec2e316251a8ff9.png',
				}, {
					image: 'https://s3.bmp.ovh/imgs/2022/08/02/6ec2e316251a8ff9.png',
				}],
				user:null,
				//就诊人信息列表
				patientList: [
					[{
						id: 1,
						image: 'https://s3.bmp.ovh/imgs/2022/08/22/dc720e5d0256c3dd.png',
						name: '张三',
						balance: '300',
						cardNo: '85245685296311245'
					}, {
						id: 2,
						image: 'https://s3.bmp.ovh/imgs/2022/08/22/dc720e5d0256c3dd.png',
						name: '李四',
						balance: '120',
						cardNo: '85245685296311246'
					}, {
						id: 3,
						image: 'https://s3.bmp.ovh/imgs/2022/08/22/dc720e5d0256c3dd.png',
						name: '王五',
						balance: '200',
						id: 4,
						cardNo: '85245685296311247'
					}]
				],
				///门诊服务菜单
				outpatientServiceList: [{
					url: '../../static/appointmentRegister.png',
					title: '预约挂号'
				},{
					url: '../../static/prescription.png',
					title: '药品查询'
				}],
				outpatientServiceList2: [{
					url: '../../static/prescription.png',
					title: '药品查询'
				}],
				// , {
				// 	url: '../../static/outpatientPay.png',
				// 	title: '就诊充值'
				// }, {
				// 	url: '../../static/rechargeRecord.png',
				// 	title: '充值记录'
				// },
				// {
				// 	url: '../../static/outpatientOrder.png',
				// 	title: '门诊缴费'
				// }, 
				// {
				// 	url: '../../static/nucleicAcidTesting.png',
				// 	title: '核酸检测'
				// }, {
				// 	url: '../../static/prescription.png',
				// 	title: '处方查询'
				// }, {
				// 	url: '../../static/smartLeadingExamining.png',
				// 	title: '智能引导'
				// },
				//],
				//住院服务菜单
				// patientServiceList: [{
				// 	url: '../../static/informationSearch.png',
				// 	title: '信息查询'
				// }, {
				// 	url: '../../static/hospitalListing.png',
				// 	title: '住院清单'
				// }],
				reportSearchList: [{
					url: '../../static/inspectionReport.png',
					title: '医生管理'
				}, {
					url: '../../static/surveyReport.png',
					title: '患者管理'
				}],
				reportSearchList2: [{
					url: '../../static/smartLeadingExamining.png',
					title: '科室排班'
				},{url: '../../static/prescription.png',
					title: '药品管理'}],
				
				// {
				// 	url: '../../static/nucleicAcidReport.png',
				// 	title: '核酸报告'
				// },
				
			}
		},
		onLoad() {
			this.user = appRequest.getUserInfo();
			if(!this.user){
				uni.redirectTo({
					url:"/pages/login/login"
				})
			}
		},
		methods: {
			
			toUserCenter(){
				uni.navigateTo({
					url:"/pages/manager/addUser"
				})
			},
			logout(){
				uni.reLaunch({
					url:"/pages/login/login"
				})
			},
			// 确认当前就诊人
			confirmPatient(e) {
				this.nowPatient = e.value[0]
				this.showPatientList = false
			},
			//更新当前就诊人
			changePatient() {
				if (this.patientList.length == 0) {
					return uni.showToast({
						title: '没有更多的就诊人'
					})
				} else {
					this.showPatientList = true
				}
			},
			//我的就诊人
			myVisitors() {
				uni.navigateTo({
					url: '/pages/registrationRecord/registrationRecordHis'
				})
			},
			//添加就诊人
			addVisitors() {
				uni.navigateTo({
					url: '/pages/addVisitors/addVisitors'
				})
			},
			//电子就诊卡
			QrCodeImg() {
				uni.previewImage({
					urls: [this.nowPatient.image],
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {},
						fail: function(err) {}
					}
				});
				// uni.navigateTo({
				// 	url:'/pages/CRM_MedicalCard/CRM_MedicalCard'
				// })
			},
			//挂号记录
			registrationRecord() {
				uni.navigateTo({
					url: '/pages/registrationRecord/registrationRecord'
				})
			},
			//预约挂号
			navigatorPages(item) {
				if (item.title == '预约挂号') {
					uni.navigateTo({
						url: '/pages/chooseClinic/chooseClinic'
					})
				} else if (item.title == '就诊充值') {
					uni.navigateTo({
						url: '/pages/cardPay/cardPay'
					})
				} else if (item.title == '充值记录') {
					uni.navigateTo({
						url: '/pages/payRecord/payRecord'
					})
				} else if (item.title == '核酸检测') {
					uni.navigateTo({
						url: '/pages/nucleicAcidTesting/nucleicAcidTesting'
					})
				} else if (item.title == '处方查询') {
					uni.navigateTo({
						url: '/pages/prescriptionSearch/prescriptionSearch'
					})
				} else if (item.title == '智能引导') {
					uni.navigateTo({
						url: '/pages/guidanceList/guidanceList'
					})
				} else if (item.title == '检查报告') {
					uni.navigateTo({
						url: '/pages/surveyReportList/surveyReportList?type=1'
					})
				} else if (item.title == '检验报告') {
					uni.navigateTo({
						url: '/pages/surveyReportList/surveyReportList?type=2'
					})
				} else if (item.title == '医生管理') {
					uni.navigateTo({
						url: '/pages/manager/userManager?type=3'
					})
				}else if (item.title == '患者管理') {
					uni.navigateTo({
						url: '/pages/manager/userManager?type=2'
					})
				}else if(item.title =="科室排班"){
					uni.navigateTo({
						url: '/pages/manager/jobManager'
					})
				}else if(item.title=="药品管理"){
					uni.navigateTo({
						url: '/pages/manager/medicineManager'
					})
				}else if(item.title=="药品查询"){
					uni.navigateTo({
						url: '/pages/manager/medicineManager'
					})
				}
			}
		}
	}
</script>
<style>
	page {
		width: 100%;
		height: 100%;
		background-color: #F7F7F7;
	}
</style>
<style scoped lang="scss">
	.content {
		padding: 20rpx;
		background-color: #F7F7F7;

		.attendanceUserInfo {
			margin-top: 20rpx;
			background-color: #FFFFFF;
			border-bottom: 10rpx solid #78C0EB;

			.guide {
				height: 35rpx;
				display: flex;
				align-items: center;
				justify-content: flex-end;
				font-size: 24rpx;
				color: #FFFFFF;
				padding: 0 20rpx;
				background: linear-gradient(74deg, #78C0EB, #79C0EA);
			}

			.addVisitorsBox {
				height: 140rpx;
				display: flex;
				align-items: center;
				justify-content: center;

				.addVisitors {
					height: 70rpx;
					width: 350rpx;
					font-size: 24rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					color: #FFFFFF;
					letter-spacing: 4rpx;
					background: linear-gradient(90deg, #5088FD 0%, #62B9F9 100%);
					border-radius: 6rpx;
				}
			}

			.top {
				display: flex;
				justify-content: space-between;
				padding: 10rpx 60rpx;
				border-bottom: 1px dashed #D3D3D3;

				.left {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					color: #706F6F;

					.name {
						display: flex;
						font-size: 40rpx;
						letter-spacing: 4rpx;
						font-weight: bold;

						.label {
							color: #454545;
							margin-right: 10rpx;
						}
					}

					.balance {
						display: flex;
						font-size: 33rpx;

						.money {
							color: #4095D2;
							letter-spacing: 4rpx;
						}
					}
				}

				.right {
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					font-size: 20rpx;
					letter-spacing: 2rpx;

					.label {
						margin-top: 10rpx;
					}

					.QrCodeImg {
						width: 84rpx;
						height: 84rpx;
					}
				}
			}

			.bottom {
				display: flex;
				justify-content: space-between;
				padding: 20rpx 0;

				.bottomItem {
					display: flex;
					flex: 1;
					justify-content: center;
					align-items: center;
					font-size: 25rpx;
					color: #656565;

					.image {
						width: 35rpx;
						height: 35rpx;
						margin-right: 30rpx;
					}
				}

				.bottomItem:first-child {
					border-right: 1px solid #78C0EB;
				}
			}
		}

		.outpatientService,
		.patientService,
		.reportSearch {
			margin-top: 20rpx;

			.itemList {
				margin-top: 20rpx;
				background-color: #FFFFFF;
				padding: 0rpx 20rpx 30rpx;

				/deep/.u-grid-item {
					margin-top: 30rpx;
				}

				.grid-text {
					font-size: 28rpx;
					color: #909399;

				}
			}
		}
	}
</style>
